
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef struct TreeNode
{
	int data;
	struct TreeNode* lchild;
	struct TreeNode* rchild;
}TreeNode;
void creatTree(TreeNode** t,int* index,char* data)
{
	char ch;
	ch = data[*index];
	(*index)++;
	if (ch == '#')
		*t = NULL;
	else
	{
		*t = (TreeNode*)malloc(sizeof(TreeNode));
		assert(*t);
		(*t)->data = ch;
		creatTree(&((*t)->lchild),index,data);
		creatTree(&((*t)->rchild),index,data);
	}
}
void preOrder(TreeNode* t)
{
	if (t == NULL)
		return;
	else
	{
		printf("%c", t->data);
		preOrder(t->lchild);
		preOrder(t->rchild);
	}
}
void midOrder(TreeNode* t)
{
	if (t == NULL)
		return;
	else
	{
		preOrder(t->lchild);
		printf("%c", t->data);
		preOrder(t->rchild);
	}
}
void lastOrder(TreeNode* t)
{
	if (t == NULL)
		return;
	else
	{
		preOrder(t->lchild);
		preOrder(t->rchild);
		printf("%c", t->data);
	}
}
int main()
{
	TreeNode* t;
	int index=0;
	char data[100];
	gets_s(data);
	creatTree(&t,&index,data);
	preOrder(t);
	printf("\n");
	midOrder(t);
	printf("\n");
	lastOrder(t);
	return 0;
}
